/*
 * Copyright (C) 2008 Peter Kling
 * 
 * This file is part of 'A Kind of Billiard', a graphical billiard simulation.
 * 
 * 'A Kind of Billiard' is free software: you can redistribute it and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 * 
 * 'A Kind of Billiard' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with 'A Kind of Billiard'. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package de.akob.misc;

import javax.media.opengl.GL;

/**
 * A simple wrapper class for OpenGL drawables, that allows to apply arbitray translations to the drawable.
 */
public class TranslatedOpenGLDrawable implements OpenGLDrawable {
	private final OpenGLDrawable drawable;
	private final double         dx, dy, dz;
	
	/**
	 * Standard constructor.
	 */
	public TranslatedOpenGLDrawable(OpenGLDrawable drawable, double dx, double dy, double dz) {
		this.drawable = drawable;
		this.dx = dx;
		this.dy = dy;
		this.dz = dz;
	}
	
	/**
	 * Draws the translated OpenGL drawable.
	 */
	public void draw(GL gl) {
		gl.glPushMatrix();
		gl.glTranslated(dx, dy, dz);
		drawable.draw(gl);
		gl.glPopMatrix();
	}
}
